﻿using System.Net.NetworkInformation;
using System.Text;

namespace XyLicense.Library
{
    public class ComputerHelper
    {
        public static string GetComputerDetail()
        {
            StringBuilder sb = new StringBuilder("[");
            try
            {
                NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
                foreach (NetworkInterface networkInterface in networkInterfaces)
                {
                    if (networkInterface.OperationalStatus == OperationalStatus.Up)
                    {
                        PhysicalAddress macAddress = networkInterface.GetPhysicalAddress();
                        string t = macAddress.ToString();
                        if (!string.IsNullOrWhiteSpace(t) && !t.Equals("000000000000"))
                        {
                            if (sb.Length > 1)
                            {
                                sb.Append($",\"{t}\"");
                            }
                            else
                            {
                                sb.Append($"\"{t}\"");
                            }

                        }
                    }                   
                }
            }
            catch
            {
            }


            sb.Append("]");

            return sb.ToString();
        }

    }
}